﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="selectproduct.aspx.cs" Inherits="UI.system.page.ad.selectproduct" %>
<style>
    td img{object-fit:cover; width:80px; height:50px;}
    .layer-page{position:absolute;}
</style>
<div class="layui-form" style="margin-bottom:50px; padding:10px; position:relative;">
    <div class="layui-searchbar">
        <div class="left"><div class="layui-input-inline" style="margin-right:5px;"><input id="keyword" type="text" name="name" placeholder="产品名称"  class="layui-input" value="" style="height:30px; line-height:30px;"></div><div class="layui-input-inline"><a class="layui-btn layui-btn-small" onclick="Search()">搜索</a></div></div>
        <div class="right"><a id="search" class="layui-btn layui-btn-small layui-btn-normal" onclick="Sure()">确定</a></div>
    </div>
    <table class="layui-table">
    <colgroup>
      <col width="80">
      <col width="80">
      <col>
      <col width="140">
    </colgroup>
    <thead>
      <tr>
        <th>单选</th>
        <th>图片</th>
        <th>产品名称</th>
        <th>创建时间</th>
      </tr> 
    </thead>
     <tbody id="layer-table">
        <tr><td colspan="4" class="center">数据加载中...</td></tr>
    </tbody>
    <script id="data-table" type="text/html">
      {{#  layui.each(d, function(index, item){ }}
      <tr id="{{item.ID}}" class="cursor">
        <td><input type="radio" name="id" value="{{item.ID}}" title=" " lay-filter="froms"></td>
        <td><img src="{{item.Img}}"/></td>
        <td>{{item.Name}}</td>
        <td>{{item.CreateDate.ToTime()}}</td>
      </tr>
      {{#  }); }}
      </script>
  </table>
</div>
<div id="layer-page" class="layer-page" style="bottom:0px;"></div>
<script>
    Init_Pager(1);
    function Init_Pager(page) {
        var data = {};
        data.act = "Find_Product";
        data.page = page;
        data.limit = 20;
        data.keyword = $("#keyword").val();
        data.sign = GetSign(data.act);
        Loading();
        Ajax.Post("/tools/Admin.ashx", data, function (r) {
            var json = $.parseJSON(r);
            if (json.state) {
                Pager(json.data, json.count, function () {
                    $("#layer-table tr").dblclick(function () {
                        var td = $(this).find("td");
                        $("#productid").attr("val", $(this).attr("id")).html(td[2].innerHTML);
                        LayerBox.Close.ByIndex(product_index);
                    });
                });
            }
            else {
                LayerBox.Error(json.msg);
            }
        });
    };

    function Sure() {
        var id = $("#layer-table input[name='id']:checked").val();
        var title = $("#layer-table input[name='id']:checked").parent().parent().find("td")[2].innerHTML;
        $("#productid").attr("val", id).html(title);
        LayerBox.Close.ByIndex(product_index);
    };
    
</script>